package com.code.day16.b_thread;

public class Consumer implements Runnable{
    private BaoZiPu bzp;
    public Consumer(BaoZiPu bzp) {
        this.bzp = bzp;
    }


    @Override
    public void run() {
        while ( true){

            try {
                Thread.sleep(100l);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            synchronized (bzp) {

                if (!bzp.isFlag()) {
                    try {
                        bzp.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                bzp.getCount();
                bzp.setFlag(false);
                bzp.notify();


            }




        }
    }
}
